import Tree from "./Tree"

export default ({ data, show = true, setShow }: any) => {

  return <ul style={{ display: show ? 'block' : 'none' }}>
    {
      Array.isArray(data) && data.length && data.map(item => {
        return <li key={item.value} onClick={(event) => {
          setShow(item)
          // 清除冒泡
          event.stopPropagation()
        }}>
          {item.value}
          {/* 递归组件 */}
          {
            item.children && <Tree setShow={setShow} data={item.children} show={item.show}></Tree>
          }
        </li>
      })
    }
  </ul>
}